<html>
<head>
<style>

body {
   padding: 0px;
   font-family: sans-serif;
   color: ----color----;
}
 .content-wrapper {
    width: 100%;
    height: 100%;
    display: table;
 }

 .content-wrapper #translation {
    text-align: center;
    vertical-align: middle;
    display: table-cell;
 }
 .dark-mode{
 	color:white;
 }

</style>
</head>
<body>
<div class="content-wrapper">
    <h3 id="translation" > </h3>
</div>

<script>
   var from_lang = "----fromlang----";
    var to_lang = "----tolang----";
    var disabled = false,
        BASE_URL = "http://translate.google.es/translate_a/single?client=t&sl=" + from_lang + "&tl="+
        to_lang + "&hl="+ to_lang + 
        "&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=sw&ie=UTF-8&oe=UTF-8&ssel=0&tsel=3&otf=1&&q=";

    var translate = function translate(words) {
        ajaxRequest(words, function(serverResponse) {
           content = processText(serverResponse);
           plotDiv(content);
        });
    }

    function ajaxRequest(words, callback) {
        var xhReq = new XMLHttpRequest(),
            serverResponse;
        xhReq.open("GET", BASE_URL + words);
        xhReq.onreadystatechange=function() {
          if (xhReq.readyState==4 && xhReq.status==200)
            {
               callback(xhReq.responseText);
            }
        }
        xhReq.send(null);
    }

    /**
    *   Gets the translated text and apply regex to clean the output.
    */
    function processText(response) {
        var translation = "",
            word,
            alternatives;
        response = response.replace(/\d+/g, '');
        response = response.split("]");
        word = response[0];
        alternatives = response[1];
        word = word.replace(/\[/g, '');
        word = word.replace(/\"/g, '');
        word = word.split(",");
        word = word[0];
        translation += word + ". ";
        translation.replace(".", ".\n");
        return translation;
    }
    
    var resultText = null;
    
    function plotDiv(text) {
       resultText = text;
      document.getElementById("translation").innerText = text;
    }
    
    function output() {
       return resultText;
    }

	 setTimeout(function() {
	 	translate("----text----");
	 }, 500);


</script>
</body>
</html>